package com.jodinfo.outmirror.controller;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/officialMain")
public class OfficialMainController {

	@RequestMapping("/main")
	public ModelAndView index(HttpServletRequest request,Model model){
		HttpSession session = request.getSession();
		ServletContext servletContext=request.getSession().getServletContext();
		session.setAttribute("cdnAddress", servletContext.getInitParameter("cdnAddress"));
		String projectName = request.getContextPath();
		session.setAttribute("projectName",projectName);
		return new ModelAndView(returnPath("main")); 
	}
	@RequestMapping("/login")
	public  String login(HttpServletRequest request,Model model) {
		HttpSession session = request.getSession();
		ServletContext servletContext=request.getSession().getServletContext();
		session.setAttribute("cdnAddress", servletContext.getInitParameter("cdnAddress"));
		String projectName = request.getContextPath();
		session.setAttribute("projectName",projectName);
		return "login";
	}
	
	@RequestMapping("/index")
	public  ModelAndView indexModel(HttpServletRequest request,Model model) {
		return new ModelAndView(returnPath("indexNew")); 
	}
	
	@RequestMapping("/manage")
	public  String backManagement(HttpServletRequest request,Model model) {
		return "manage";
	}
	
	/**
	 * 定义
	 * 
	 */
	private final String MODULE_PATH = "";

	//返回路径
	private String returnPath(String jspName) {
		return MODULE_PATH + jspName;
	}
	
}
